﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class par : System.Web.UI.Page
{
	enum ProcessType {
		NameUniqueCheck=0,
		ExitSystem=1,
		DownloadArchive=2,
		DeleteUser=3,
		BaseRoleChange=4,
		DeleteArchive=5,
		TopTopicMode=6,//置顶切换
		ExcellentMode=7,//加精切换
		DeleteTopic=8,//删除帖子
	}
    protected void Page_Load(object sender, EventArgs e)
    {
		//this.Response.ContentEncoding = System.Text.Encoding.UTF8;
		//this.Response.Charset = "utf-8";
		//this.Response.ContentType = "";
		String typeS = Request.QueryString["t"];
		Int32 type;
		if (Int32.TryParse(typeS,out type))
		{
			switch ((ProcessType)type)
			{
				case ProcessType.NameUniqueCheck:
					String name=this.Request.QueryString["name"];
					if (name == "" || name == null)
						this.Response.Write("用户名不能为空！");
					else if (DAMS.DataAccess.GetUserID(name)==SE6.User.NON_EXISTS_ID)
						this.Response.Write("恭喜！您的用户名尚未被注册");
					else
						this.Response.Write("sorry！您选定的名字已被人抢注啦~");
					break;
				case ProcessType.ExitSystem:
					SessionMan.SaveLoginUser(null);
					Response.Redirect("Default.aspx");
					break;
                case ProcessType.DownloadArchive:
                    ArchiveMan.Download(Request, Response);
                    break;
				case ProcessType.DeleteUser:
					String res=SE6.UserMan.DeleteUser(Request);
					SessionMan.SaveResult(res);
					Response.Redirect(Request.UrlReferrer.ToString());
					break;
				case ProcessType.BaseRoleChange:
					SessionMan.SaveResult(SE6.UserMan.ChangeBaseRole(Request));
					Response.Redirect(Request.UrlReferrer.ToString());
					break;
				case ProcessType.DeleteArchive:
					SessionMan.SaveResult(ArchiveMan.Delete(Request));
					Response.Redirect("Result.aspx");
					break;
				case ProcessType.TopTopicMode:
					SessionMan.SaveResult(BBS.ChangeTopicTopMode(Request));
					Response.Redirect(Request.UrlReferrer.ToString());
					break;
				case ProcessType.ExcellentMode:
					SessionMan.SaveResult(BBS.ChangeTopicExcellentMode(Request));
					Response.Redirect(Request.UrlReferrer.ToString());
					break;
				case ProcessType.DeleteTopic:
					SessionMan.SaveResult(BBS.DeleteTopic(Request));
					Response.Redirect("Result.aspx");
					break;
				default:
					Response.Redirect("error.aspx");
					break;
			}
		}		
    }
}
